<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width,initial-scale=1.0">
        <title>【券易购】一个帮您购物省钱，还能赚钱的平台</title>
        <meta name="description" content="券易购公众号，这里汇集淘宝、京东、拼多多全网优惠券，购物可省钱，分享能赚钱，大家都在用的购物好帮手，赶紧关注试一试吧" />
        <meta name="keyword" content="券易购,优惠券,淘宝优惠券,京东优惠券,拼多多优惠券,隐藏优惠券,返利,购物返利,返利平台,分享购物返利,分销返利,佣金,购物佣金,佣金平台,分享购物佣金,分享购物佣金,赚钱好副业" />
        <link rel="shortcut icon" type="image/ico" href="./images/favicon.ico"/>
        <link rel="stylesheet" href="./css/reset.css">
        <link rel="stylesheet" href="./css/home.css">
        <link rel="stylesheet" href="./css/product.css">
        <link rel="stylesheet" href="./css/swiper.min.css">
        <style>
            html, body {background-color: #f2f2f2;}
            .loading, .none-data, .end-data {font-size: 16px;color: #999;text-align: center;padding: 30px 0;}
            .none-data, .end-data {display: none;}
        </style>
    </head>
    <body>
        <div class="navy-bar-box">
            <div class="contain-width dis-flex navy-bar">
                <div class="dis-flex align-item logo-box">
                    <img src="./images/logo.png" alt="">
                    <span>券易购</span>
                </div>
                <ul class="clearfix">
                    <li class="handle-to-home"><a href="./home.html">首页</a></li>
                    <li><a href="./baoyou.html">1.9包邮</a></li>
                    <li><a href="./baokuan.html">今日爆款</a></li>
                    <li class="active"><a href="javascript:;">品牌清仓</a></li>
                    <li><a href="./chaoji.html">超级返</a></li>
                </ul>
            </div>
        </div>
        <div class="main-content">
            <img src="./images/top-bg03.png" class="top-banner-bg">
            <div class="hot-promotion-wrapper hot-promotion-list">
                <div>
                    <div class="clearfix hot-promotion-list-scroll">
                    </div>
                </div>
            </div>
            <p class="loading">商品加载中...</p>
            <p class="none-data">未找到相关商品</p>
            <p class="end-data">商品已加载完毕</p>
        </div>
        <footer class="footer">
            <div class="dis-flex contain-width footer-box">
                <div>
                    <a href="javascript:;">公司名称：深圳市高博信息科技有限公司</a>
                    <p>商务合作：270822268@qq.com</p>
                   <!--  <a href="javascript:;">备案信息XXXX</a> -->
                </div>
                <div><img src="./images/qrcode.jpg" alt=""></div>
            </div>
        </footer>
        <div class="keep-on-record">&copy;2019 深圳高博信息科技有限公司&emsp;版权所有&ensp;&ensp;&ensp;&ensp;<a href="http://beian.miit.gov.cn" target="_blank">粤ICP备19148424号</a></div>
        <script src="./js/jquery-1.8.3.min.js"></script>
        <script src="./js/common.js"></script>
        <script>
            $(function() {
                var ruuner = {
                    pageNo: 1,
                    pageSize: 40,
                    type: 0,
                    loading: false,
                    total: 0,
                    isEndData: false,
                    init: function() {
                        this.getData();
                        this.bindEvent();
                    },
                    dealData: function(data) {
                        var html = '',
                            length = data.length;
                        for(var i = 0; i < length; i++) {
                            html += '<a href="javascript:;">';
                            html += '<div class="jinbao-single-goods-card ">';
                            html += '    <div class="jinbao-goods-card-hover-wrapper ">';
                            html += '        <div class="img-wrapper">';
                            html += '            <img src="' + data[i].goodsThumbnailUrl + '">';
                            html += '        </div>';
                            html += '        <div class="goods-info">';
                            html += '            <p class="goods-title">';
                            html += '                <span class="text">' + data[i].goodsName + '</span>';
                            html += '            </p>';
                            html += '            <div class="data-info">';
                            html += '                <div class="data-block">';
                            html += '                    <span class="data-price left-align">';
                            html += '                        <span class="unit">￥</span>';
                            var price = utils.pointToCorner(+data[i].minGroupPrice);
                            html += '                        <span class="unit-left">' + price + '</span>';
                            html += '                    </span>';
                            if(data[i].hasCoupon) {
                                html += '                    <span class="data-text">券后</span>';
                            }else {
                                html += '                    <span class="data-text">价格</span>';
                            }
                            html += '                </div>';
                            html += '                <div class="data-block">';
                            html += '                    <span class="data-num left-align">';
                            html += '                        <span class="unit">￥</span>';
                            if(data[i].hasCoupon) {
                                var couponDiscount = utils.pointToCorner(+data[i].couponDiscount, 0);//优惠券价格
                                var afterCouponPrice = utils.dealPricePoint(utils.numSub(+price, +couponDiscount));
                                var canEarn = utils.canEarn(data[i].promotionRate, afterCouponPrice);//预估可赚金额
                            }else {
                                var canEarn = utils.canEarn(data[i].promotionRate, price);//预估可赚金额
                            }
                            html += '                        <span class="unit-left">' + canEarn + '</span>';
                            html += '                    </span>';
                            html += '                    <span class="data-text">佣金</span>';
                            html += '                </div>';
                            html += '                <div class="data-block">';
                            var rate = utils.numMulti(data[i].promotionRate, 0.1, 0);
                            html += '                    <span class="data-num">' + rate + '%</span>';
                            html += '                    <span class="data-text">比率</span>';
                            html += '                </div>';
                            html += '            </div>';
                            html += '            <div class="label-info">';
                            if(data[i].hasCoupon) {
                                html += '                <div class="coupons-info">';
                                var couponDiscount = utils.pointToCorner(+data[i].couponDiscount, 0);//优惠券价格
                                html += '                    <span class="coupon-discount">' + couponDiscount + '元券</span>';
                                html += '                    <span class="coupon-surplus">剩' + data[i].couponRemainQuantity + '张</span>';
                                html += '                </div>';
                            }
                            html += '            </div>';
                            html += '            <div class="sale-info">';
                            html += '                <div class="goods-sale">销量' + data[i].salesTip + '</div>';
                            html += '                <div class="store-name">' + data[i].mallName + '</div>';
                            html += '            </div>';
                            html += '        </div>';
                            html += '    </div>';
                            html += '</div>';
                            html += '</a>';
                        }
                        return html;
                    },
                    getData: function() {
                        this.loading = true;
                        var offset = (this.pageNo - 1) * this.pageSize;
                        var self = this;
                        var data = JSON.stringify({
                            'channelType': 2,
                            'limit': this.pageSize,
                            'offset': offset
                        });
                        $.ajax({
                            url: 'https://shophdd.com/hdd/pdd/product/goodsRecommendGet',
                            type: "POST",
                            data: data,
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function(respond){
                                self.loading = false;
                                if(respond.code === '0000') {
                                    var result = respond.data.productInfoResps,
                                        length = result.length;
                                    if(length > 0) {
                                        var data = self.dealData(result);
                                        $('.hot-promotion-list-scroll').html(data);
                                        self.total = respond.data.total;
                                        var page = self.pageNo + 1;
                                        if((page * self.pageSize) >= self.total) {
                                            $('.loading').css('display', 'none');
                                            $('.end-data').css('display', 'block');
                                            self.isEndData = true;
                                        }
                                    }else {
                                        $('.loading').css('display', 'none');
                                        $('.none-data').css('display', 'block');
                                    }
                                }
                            }
                        });
                    },
                    loadMore: function() {
                        this.loading = true;
                        this.pageNo++;
                        var offset = (this.pageNo - 1) * this.pageSize;
                        var self = this;
                        var data = JSON.stringify({
                            'channelType': 2,
                            'limit': this.pageSize,
                            'offset': offset
                        });
                        $.ajax({
                            url: 'https://shophdd.com/hdd/pdd/product/goodsRecommendGet',
                            type: "POST",
                            data: data,
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function(respond){
                                self.loading = false;
                                if(respond.code === '0000') {
                                    var result = respond.data.productInfoResps,
                                        length = result.length;
                                    var data = self.dealData(result);
                                    $('.hot-promotion-list-scroll').append(data);
                                    self.total = respond.data.total;
                                    var page = self.pageNo + 1;
                                    if((page * self.pageSize) >= self.total) {
                                        $('.loading').css('display', 'none');
                                        $('.end-data').css('display', 'block');
                                        self.isEndData = true;
                                    }
                                }
                            }
                        });
                    },
                    bindEvent: function() {
                        var self = this;
                        $(window).scroll(function () {
                            if(self.loading || self.isEndData) return;
                            //$(window).scrollTop()这个方法是当前滚动条滚动的距离
                            //$(window).height()获取当前窗体的高度
                            //$(document).height()获取当前文档的高度
                            var bot = 200; //bot是底部距离的高度
                            if((bot + $(window).scrollTop()) >= ($(document).height() - $(window).height())) {
                                //当底部基本距离+滚动的高度〉=文档的高度-窗体的高度时；
                                //我们需要去异步加载数据了
                                self.loadMore();
                            }
                        });
                    }
                };
                ruuner.init();
            });
        </script>
    </body>
</html>
